<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%@include file="./common/base.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>有而就是有范儿</title>
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>

</head>

<body>
<div class="outer-wrapper noimgbg3">
<%@ include  file="./common/header.jsp"%>
    <!--content -->
    <div class="content-4 clear">
    	<div class="content-4-left fl" onclick="leftCard();"></div>
    	<!-- user list row 1-->
        <div class="fl" id="recommendId">
        </div><!--user list row 1 end -->
		<div class="content-4-right fl" onclick="rightCard();"></div>
    </div><!--content-n end -->
    <div style="height:500px; background-color:#1a1a1a; margin-top: 30px;">
    	<div style="">
        	<div style="color:#fff; margin:0px auto; width: 700px; padding-top: 20px; font-size: 16px;">
            <a href="#" style="color:#fff; ">最热</a>
            &nbsp;&nbsp;|&nbsp;&nbsp;
            <a href="#" onclick="changeIt();" style="color:#fff; ">换一组</a>
			</div>
        </div>
        <div style="width: 1170px; heigth:298px;margin: 30px auto; text-align:center;" id="viewCardId">
	       
        </div>
    </div>
        <!--footer -->
    <%@ include  file="./common/footer.jsp"%>
    <!--footer end -->
</div>
<!-- Snake Change 20141209 -->
<div class="mailBG"></div>
<div class="mailContent">
	<div style="height: 40px;line-height: 40px;background-color: #f15a24;text-align: center;color: white;font-size: 16px;">
		发送邮件
		<div style="cursor: pointer;position: absolute;left: 480px;top: 11px;">
			<img src="image/mailClose.png" alt="close" title="关闭" class="mailClose" />
		</div>
	</div>
	<div style="height: 200px;margin-top: 25px;">
		<div style="float: left;font-size: 16px;margin: 0 20px;">内容</div><textarea id="mailContentDId" style="width: 400px;height: 200px;border-color: #b2b2b2" rows="0" cols="0"></textarea>
	</div>
	<div style="margin: 0 auto;width: 165px;margin-top: 20px;">
		<div style="width: 180px;height: 35px;line-height: 35px;text-align: center;background-color: #f15a24;color: white;font-size: 16px;cursor: pointer;" onclick="sendMailByDiscover();">
			发送
		</div>
	</div>
</div>
<!-- Snake Change 20141209 -->
</body>
<script>
var pageIndex=0
var limit = 3;
$(function() { 
	if(!checkLogin()){
		return;
	}
	loadViewCard(pageIndex,limit);
	loadRecommendList();
});
var discoverCardId=0;
function setCardIdDiscover(cardId) {
	discoverCardId = cardId
}
function sendMailByDiscover() {
	var cardId = discoverCardId;
	var title="来自youoor的邮件";
	var contentDiv = $("#mailContentDId");
	var content =contentDiv.val();
	if(content==null||content=="") {
		alert("发送内容不能为空");return;
	}
	sendMailByYouoor(cardId,title,content);
	$('.mailBG').fadeOut(800);
	$('.mailContent').fadeOut(800);
	contentDiv.val("");
}
function changeIt() {
	pageIndex = pageIndex+1;
	if (pageIndex==3) {
		pageIndex = 0;
	}
	loadViewCard(pageIndex,limit)
}

function loadViewCard(pageIndex,limit){
	objp= {}
	objp.pageIndex = pageIndex;
	objp.limit = limit;
	   $.ajax({
			  url: '${path}/core/getViewCard',
			  type: 'POST',
			  timeout: 30000,
			  cache : false,
		      data :objp,
		      async: false,
			  success:function(msg){
				  setViewVCardInfo(msg.viewCardList)
			  },
			   failure:function(msg){
				   alert(eval('('+msg.responseText+')').error_text);
			   		
			   },
			   error:function(msg){
				   alert(eval('('+msg.responseText+')').error_text); 
			   }
		});
}

function setViewVCardInfo(userCardList) {
	if (userCardList) {
		var viewCardDiv = $("#viewCardId");
		if(userCardList.length!=0) {
			viewCardDiv.empty();
		}
		
		for(var k=0;k<userCardList.length;k++) {
			if(userCardList.length-1==k) {
				viewCardDiv.append("<img   class=\"divImg1\" onclick = \"toViewCard("+userCardList[k].cardId+")\" src=\""+imgDomain+userCardList[k].background+"\"  style=\"cursor:pointer;overflow:hidden;\"/>");
			}else{
				viewCardDiv.append("<img   class=\"divImg1\" onclick = \"toViewCard("+userCardList[k].cardId+")\" src=\""+imgDomain+userCardList[k].background+"\" style=\"margin-right:10px;cursor:pointer;overflow:hidden;\" />");
			}
			
		}
	} 
}
var index=0;
var tmpRecommList=null;
var recommendLength=0;
function loadRecommendList(){
	objp= {}
	objp.limit = 5;
	   $.ajax({
			  url: '${path}/core/getViewRecommendCard',
			  type: 'POST',
			  timeout: 30000,
			  cache : false,
		      data :objp,
		      async: false,
			  success:function(msg){
				  setRecommendInfo(msg.infoList,index)
			  },
			   failure:function(msg){
				   alert(eval('('+msg.responseText+')').error_text);
			   		
			   },
			   error:function(msg){
				   alert(eval('('+msg.responseText+')').error_text); 
			   }
		});
	
}

function setRecommendInfo(recommendList,index){
	if(recommendList && recommendList.length > 0 ) {
		tmpRecommList=recommendList;
		recommendLength=recommendList.length-1;
		recommDiv = $("#recommendId");
		recommDiv.empty();
		//for(var k=0;k<recommendList.length;k++) {
		var k=index;
		var linkDiv = formatLinkData(recommendList[k].links);
		var randomId=generateMixed(11);
		recommDiv.append("<div class=\"content-list4\">"+
							"<div class=\"user-img fl\">"+
								"<img alt=\"head\" class=\"divImg1\"  onclick=\"toViewCard("+recommendList[k].userCard.cardId+")\"  src=\""+imgDomain+recommendList[k].userCard.background+"\"/>"+
						    "</div>"+
						    "<div class=\"content-userinfo content_userinfo_s fl\">"+
						        "<h2 class=\"userinfo-title\">"+recommendList[k].userCard.name+"</h2>"+ 
							    "<ul class=\"userinfo-share  userinfo-share-s\">"+ 
							    	linkDiv+
						        "</ul>"+ 
						        "<p class=\" user-remark user-remark-n mt5\">"+recommendList[k].userCard.description+"</p>"+
						        "<ul class=\"location\">"+
						        	"<li><a href=\"javascript:void(0);\" class=\"up\">"+recommendList[k].userCard.location+"</a></li>"+
						            "<li><a href=\"javascript:void(0);\" class=\"mid\">"+recommendList[k].userCard.occupation+"</a></li>"+
						            "<li><a href=\"javascript:void(0);\" class=\"down\">"+recommendList[k].userCard.hobby+"</a></li>"+
					        	"</ul>"+
					            "<ul class=\"widget clear\">"+
						        	"<li id=\""+randomId+"\" class=\"share-op-li share-op-li-s share-op-li-c"+recommendList[k].userCard.styleInt+"\" onMouseOver='onMouseOverShare(\""+randomId+"\",\""+recommendList[k].userCard.cardId+"\",\""+recommendList[k].userCard.background+"\");' onMouseOut='onMouseOutShare(\""+randomId+"\");'>"+
						            	"<a href=\"javascript:void(0);\" class=\"share-op share-op"+recommendList[k].userCard.styleInt+"\">2</a>"+
						            	"<div class=\"bg-long bg-lt bg-long-c"+recommendList[k].userCard.styleInt+"\"  style=\"display:none;\">"+
						                    "<p>分享到：</p>"+
						                    "<ul class=\"share-pop-in\">"+
							                    "<li><a href=\"javascript:void(0);\" class=\"pop-sina\" onclick=\"javascript:bShare.share(event,'sinaminiblog',0);\">新浪网</a></li>"+
					                            "<li><a href=\"javascript:void(0);\" class=\"pop-tengxun\" onclick=\"javascript:bShare.share(event,'qqmb',0);\">腾讯</a></li>"+
					                            "<li><a href=\"javascript:void(0);\" class=\"pop-happy\" onclick=\"javascript:bShare.share(event,'kaixin001',0);\" >开心网</a></li>"+
					                            "<li><a href=\"javascript:void(0);\" class=\"pop-douban\" onclick=\"javascript:bShare.share(event,'douban',0);\">豆瓣</a></li>"+
						                    "</ul>"+
						                "</div>"+           	
						            "</li>"+
						            "<li class=\"share-op-li share-op-li-s share-op-li-c"+recommendList[k].userCard.styleInt+"\"><a href=\"javascript:favoCard("+recommendList[k].userCard.cardId+")\" class=\"add add"+recommendList[k].userCard.styleInt+"\">11</a></li>"+
						            "<li class=\"share-op-li  share-op-li-s share-op-li-c"+recommendList[k].userCard.styleInt+"\"><a href=\"javascript:hi("+recommendList[k].userCard.cardId+")\" class=\"say-hi say-hi"+recommendList[k].userCard.styleInt+"\">22</a></li>"+
						           "<li class=\"share-op-li  share-op-li-s share-op-li-c"+recommendList[k].userCard.styleInt+"\"><a href=\"javascript:setCardIdDiscover("+recommendList[k].userCard.cardId+")\" class=\"send-msg send-msg"+recommendList[k].userCard.styleInt+" mail\">33</a></li>"+
						        "</ul>"+
					      	"</div>"+
					    "</div>");
		//}
	}
	jQuery.getScript("js/js.js")

}

function leftCard(){
	if(index>0) {
		index = index-1;
	}else{
		alert("到头了");
	}
	setRecommendInfo(tmpRecommList,index)
}

function rightCard() {
	if(index<recommendLength) {
		index = index+1;
	}else{
		alert("到头了");
	}
	setRecommendInfo(tmpRecommList,index)
}



</script>
<script type="text/javascript" src="js/js.js"></script>
</html>
